#ifndef pktoon_RecursiveMutex_h
#define pktoon_RecursiveMutex_h

#ifndef WIN32
# include <pthread.h>
#endif
#include "ThreadConsts.h"
#include "Guard.h"

namespace catan
{
	class RecursiveMutex
	{
	public:
		RecursiveMutex();
		~RecursiveMutex();

		LockState::Enum Acquire(long timeout = -1);		// timeout is in milliseconds

		LockState::Enum TryAcquire();

		void Release();

		typedef Guard<RecursiveMutex> Guard;
	private:
#ifdef WIN32
		void* mMutex;
#else
		pthread_mutex_t mMutex;
#endif
	};
}

#endif
